home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C++
/
Frameworks
/
Sprocket Framework DR2
/
Sprocket Framework
/
UDrag.cp
< prev
next >
Wrap
Text File
|
1996-06-15
|
3KB
|
127 lines
/*
File: UDrag.cp
Project: Sprocket Framework 1.1 (DR2), released 6/15/96
Contains: Dialog utilities
To Do: ?
Sprocket Major Contributors:
----------------------------
Dave Falkenburg, producer of Sprocket 1.0
Bill Hayden, producer of Sprocket 1.1
Steve Sisak, producer of the upcoming Sprocket 2.0
Pete Alexander Steve Falkenburg Randy Thelen
Eric Berdahl Nitin Ganatra Chris K. Thomas
Marshall Clow Dave Hershey Leonard Rosenthal
Tim Craycroft Dave Mark Dean Yu
David denBoer Gary Powell
Cameron Esfahani Jon Summers Apple Computer, Inc.
Comments, Additions, or Corrections:
------------------------------------
Bill Hayden, Nikol Software <nikol@codewell.com>
*/
#include "UDrag.h"
//-----------------------------------------------------------------------------
// The standard UI for dragged objects is a 1-pixel outline of
// region to be dragged.
// Given any region, this will turn it into the 1-pixel outline.
//-----------------------------------------------------------------------------
void MakeDragOutlineRegion(RgnHandle theRgn)
{
RgnHandle tempRgn;
tempRgn = NewRgn();
if (tempRgn != NULL)
{
CopyRgn(theRgn, tempRgn);
InsetRgn(tempRgn, 1, 1);
DiffRgn(theRgn, tempRgn, theRgn);
DisposeRgn(tempRgn);
}
}
//-----------------------------------------------------------------------------
// GetDropDirectory
//
// Given a DragReference, this returns an FSSpec for the directory where the
// item was dropped.
//-----------------------------------------------------------------------------
OSErr GetDropDirectory(DragReference theDrag, FSSpecPtr dirSpec)
{
OSErr returnCode;
AEDesc theDesc;
returnCode = GetDropLocation(theDrag, &theDesc);
if ((theDesc.dataHandle != nil) && (returnCode == noErr))
{
AEDesc newDesc;
returnCode = AECoerceDesc(&theDesc, typeFSS, &newDesc);
if (returnCode == noErr)
{
BlockMoveData(*newDesc.dataHandle, dirSpec, sizeof(FSSpec));
(void) AEDisposeDesc(&newDesc);
}
(void) AEDisposeDesc(&theDesc);
}
return returnCode;
}
//-----------------------------------------------------------------------------
// DragLandedInTrash
//
// If this drag landed in the trash (compared using FindFolder) this will
// return true.
//-----------------------------------------------------------------------------
Boolean DragLandedInTrash(DragReference theDrag)
{
OSErr returnCode;
FSSpec dirSpec;
short trashVol;
long trashDirID;
Boolean wasTrashed = false;
returnCode = GetDropDirectory(theDrag, &dirSpec);
if (returnCode == noErr)
{
returnCode = FindFolder(0, kTrashFolderType, false, &trashVol, &trashDirID);
if (returnCode == noErr)
{
CInfoPBRec catInfo;
DirInfo *dpb = (DirInfo *)&catInfo;
dpb->ioCompletion = nil; // Find the dirID of the drop location,
dpb->ioNamePtr = dirSpec.name; // not its parent.
dpb->ioVRefNum = dirSpec.vRefNum;
dpb->ioDrDirID = dirSpec.parID;
dpb->ioFDirIndex = 0;
returnCode = PBGetCatInfoSync((CInfoPBPtr)dpb);
if ((trashVol == dirSpec.vRefNum) && (trashDirID == dpb->ioDrDirID))
wasTrashed = true;
}
}
return wasTrashed;
}